#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int checkyear(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
	{
		return 1;
	}
	else
		return 0;
}
int days(int year, int month)
{
	int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (month == 2 && checkyear(year) == 1)
		return arr[month] + 1;
	else
		return arr[month];
	
}
int main()
{
	int year = 0;
	int month = 0;
	while (scanf("%d %d", &year, &month) != EOF)
	{
		int ret = days(year, month);
		printf("%d", ret);
	}
	return 0;
}